<!-- 未来7天的门票总量及剩余情况 -->
<template>
  <view class="info_nav">
    <scroll-view scroll-x="true" @scroll="scrollView">
      <view class="piao_num">
        <view v-for="(i, index) in piaoInfoArr" :key="index" class="piao_item" :class="i.isLack ? 'is_lack_border' : ''"
          @click="chooseItem(i, index)">
          <view class="item_top">{{ i.dayName }}{{ i.date }}</view>
          <view class="item_center" :class="i.isLack ? 'is_lack_bg' : ''">
            <view class="center" :class="i.isLack ? 'is_lack_center_bg' : ''"
              :style="{ 'width': i.menpiaoNum / i.totalMenpiaoNum * 100 + '%' }">
            </view>

            <!-- {{ i.menpiaoNum }} -->
          </view>
          <view class="item_bottom" :class="i.isLack ? 'is_lack_color' : ''">
            <text class="" v-if="i.isLack">剩{{ i.menpiaoNum }}张</text>
            <text class="" v-else>票数充足</text>
          </view>
          <view class="is_choose" v-if="isChoose == index">
            <uni-icons type="checkmarkempty" size="14" color="#fff"></uni-icons>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>

export default {
  props: {
    // 时间条
    piaoInfoArr: {
      type: Array,
      default: () => []
    },
  },
  data() {
    return {
      isChoose: 0
    };
  },

  onLoad() {
  },

  onShow() { },

  methods: {
    // 点击某一个
    chooseItem(i, index) {
      console.log(i, index)
      if (this.isChoose != index) {
        this.isChoose = index;
        this.$emit("click-day", i)
      }
    },
    // 滚动函数
    scrollView() { },
  },
};
</script>

<style lang="scss" scoped>
// 票源紧张样式  -1
.is_lack_color {
  color: #FF0000 !important;
}

.is_lack_center_bg {
  background: #FF0000 !important;
}

.is_lack_bg {
  background: rgba(255, 100, 100, 0.22) !important;
}

.is_lack_border {
  border-color: #FF6464 !important;
}

// 票源紧张样式  -2

.info_nav {
  width: 100%;
  height: 130rpx;
  padding: 0 32rpx;

  .piao_num {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    font-size: 28rpx;
    color: #333333;

    .piao_item {
      height: 92rpx;
      width: 300rpx !important;
      border-radius: 10rpx;
      margin: 18rpx 0;
      margin-right: 16rpx;
      border: 2rpx solid #F3F3F3;
      padding: 8rpx 12rpx;
      text-align: center;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      position: relative;

      .item_top {
        width: 250rpx;
        text-align: center;
      }

      .item_center {
        margin: 0 100rpx;
        width: 80%;
        height: 8rpx;
        border-radius: 20rpx;
        background: rgba(7, 219, 159, 0.22);
        margin: 6rpx 0;
        position: relative;
        overflow: hidden;

        .center {
          position: absolute;
          left: 0;
          height: 100%;
          background: rgba(7, 220, 160, 1);
        }
      }

      .item_bottom {
        text-align: center;
        font-size: 20rpx;
        color: #0E9589;
      }

      // 选中标志
      .is_choose {
        position: absolute;
        right: 0;
        bottom: 0;
        width: 40rpx;
        height: 30rpx;
        background: #0E9589;
        border-top-left-radius: 50%;
        border-bottom-right-radius: 10rpx;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }
}
</style>
